package com.peppa.petshop.controller;
import com.peppa.petshop.service.IndentService;
import com.peppa.petshop.vo.DataVO;
import com.peppa.petshop.vo.IndentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张三
 * @since 2021-06-02
 */
@Controller
@RequestMapping({"/indent", "/manage"})
public class IndentController {
    @Autowired
    private IndentService indentService;

    @ResponseBody
    @GetMapping("/list")
    public DataVO<IndentVO> getIndent(Integer id, Integer page) {
        System.out.println("获取全部订单列表");
        DataVO<IndentVO> indentVO = indentService.getIndentVO(id, page);
        return indentVO;
    }

    @ResponseBody
    @PostMapping("/conditions")
    public DataVO conditions(Integer indentId, Integer indentStatus) {
        DataVO<IndentVO> indentVO = null;
        System.out.println("条件查询");
        if (indentId != null) {
            System.out.println("按照ID查询订单" + indentId);
            indentVO = indentService.getIndentVOById(null, null,indentId);
        } else {
            System.out.println("按照状态查看订单列表" + indentStatus);
            indentVO = indentService.getIndentVOByStatus(null, null,indentStatus);
        }
        return indentVO;
    }
}

